{
    Copyright (c) 2006 Andrew Filinsky and Melchiorre Caruso

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
}

{   Contains:

    BeeGui Internal Viewer form.

    Modifyed:

    v1.0.1 build 9155 - 2005.07.15 by Melchiorre Caruso;
    v1.0.1 build 9158 - 2005.07.24 by Melchiorre Caruso;
    v1.0.2 build 0276 - 2006.01.05 by Melchiorre Caruso;
  
    v1.0.3 build 0360 - 2006.12.28 by Melchiorre Caruso.
}

unit BeeGui_IntViewerFrm;

interface

uses
  Forms,
  Dialogs,
  Classes,
  Buttons,
  StdCtrls,
  SysUtils,
  Graphics,
  Controls,
  LResources,
  XMLPropStorage;

type
  { TIntViewerFrm }

  TIntViewerFrm = class(TForm)
    IntViewerFrm_Storage: TXMLPropStorage;
    IntViewerFrm_FontDialog: TFontDialog;
    IntViewerFrm_SaveDialog: TSaveDialog;
    IntViewerFrm_ViewMemo: TMemo;
    
    BtnFont: TBitBtn;
    BtnSave: TBitBtn;
    BtnOk: TBitBtn;

    procedure FormCreate(Sender: TObject);
    procedure BtnFontClick(Sender: TObject);
    procedure BtnSaveClick(Sender: TObject);
  private
  public
  end;

implementation

uses
  BeeGui_SysUtils;

  { TIntViewerFrm class }
  
  procedure TIntViewerFrm.FormCreate(Sender: TObject);
  var
    CfgFolder: string;
  begin
    CfgFolder := AnsiIncludeTrailingBackSlash(GetApplicationConfigDir);
    if ForceDirectories(CfgFolder) then
    begin
      IntViewerFrm_Storage.FileName := CfgFolder + ('intviewerfrm.xml');
    end;
    {$I beegui_intviewerfrm.inc}
    IntViewerFrm_Storage.Restore;
  end;
  
  procedure TIntViewerFrm.BtnFontClick(Sender: TObject);
  begin
    IntViewerFrm_FontDialog.Font := IntViewerFrm_ViewMemo.Font;
    if IntViewerFrm_FontDialog.Execute then
    begin
      IntViewerFrm_ViewMemo.Font := IntViewerFrm_FontDialog.Font;
    end;
  end;

  procedure TIntViewerFrm.BtnSaveClick(Sender: TObject);
  var
    FileName: ansistring;
  begin
    IntViewerFrm_SaveDialog.FileName := '';
    if IntViewerFrm_SaveDialog.Execute then
    begin
      FileName := IntViewerFrm_SaveDialog.FileName;
      case IntViewerFrm_SaveDialog.FilterIndex of
        1: FileName := ChangeFileExt(FileName, '.txt');
      end;
      IntViewerFrm_ViewMemo.Lines.SaveToFile(FileName);
    end;
  end;

initialization

  {$I beegui_intviewerfrm.lrs}

end.
